﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
using Standard;

namespace TestHttpModules
{
    [MetadataType(typeof(UserMetaData))]
    public partial class User : Commons.Entity.EntityBase, ISimpleUserInfo
    {
        public User()
        {
            this.Product = new List<Product>();
            this.User_Profile = new User_Profile();
        }
        public virtual User_Profile User_Profile { get; set; }
        public virtual IEnumerable<Product> Product { get; set; }
        public virtual ICollection<Product> Products { get; set; }

        #region ISimpleUserInfo 成员

        public string UserID
        {
            get { return this.ID.ToString(); }
        }

        public string Email
        {
            get { return string.Empty; }
        }

        #endregion
    }
    public class User_Ext : User
    {
    }

    public class UserMetaData
    {
        [ScaffoldColumn(false)]//是否在页面上显示，一般主键设为false,默认为true
        public int ID { get; set; }
        [Required(ErrorMessage = "请输入名称")]
        [DisplayName("名称")]
        [RegularExpression(@"^[a-zA-Z''-'\s]{6,40}$", ErrorMessage = "必须是由6到40个a-z惑A-Z的字符组成.")]
        public string Name { get; set; }
        [ScaffoldColumn(false)]
        [Required()]
        [DisplayName("状态")]
        [RegularExpression("[1-9]\\d(?<!9[1-9])\\d(?<!90[6-9])$", ErrorMessage = "必须是100~905之间的数字组成，（第一位是1－9,当第一位是9时，10位上只能是非（1－9）即只能是0，第3位在百位上不能是6－9的数字）")]
        public int Status { get; set; }

        [Required()]
        [DisplayName("密码")]
        public int Password { get; set; }
    }
}